home *** CD-ROM | disk | FTP | other *** search
/ Hardcore Gamer Resource Kit / Hardcore Gamer Resource Kit - Disc 3.iso / screensavers / saver25.zip / SOURCE.ZIP / Vector3.h < prev   
C/C++ Source or Header  |  1997-07-15  |  1KB  |  58 lines

  1. #ifndef _VECTOR3_H
  2. #define _VECTOR3_H
  3.  
  4. /*
  5.  * Vector3  - 3 dim vector
  6.  * X0,Y0,Z0 - unit vectors
  7. */
  8.  
  9. #include <math.h>
  10. #include <iostream.h>
  11.  
  12. class Vector3 {
  13. public:
  14.     float x,y,z;
  15. public:
  16.     Vector3() {x=0.0f;y=0.0f;z=0.0f;};
  17.     Vector3(float x0, float y0, float z0) {x=x0; y=y0; z=z0;} ;
  18.     Vector3(float *q) { x=q[0]; y=q[1]; z=q[2];}
  19.  
  20.     void operator =(Vector3 a);
  21.     void operator +=(Vector3 a);
  22.     void operator -=(Vector3 a);
  23.     Vector3 operator +(Vector3 a);
  24.     Vector3 operator -(Vector3 a);
  25.     Vector3 operator *(float a);
  26.     Vector3 operator /(float a);
  27.  
  28.     Vector3 operator -();
  29.  
  30.     Vector3 operator *(Vector3 a);    //cross product
  31.     float dot(Vector3 a);                    //dot product
  32.     Vector3 in(Vector3 a);                    //inner product
  33.  
  34.     float len();
  35.     Vector3 normalize();
  36.  
  37. //  friend ostream &operator<<(ostream &strm, const Vector3 &a);
  38.     friend class Matrix33;
  39.     friend class Quat;
  40.     friend class Camera;
  41. };
  42.  
  43.  
  44. /*
  45.  * Unit vectors
  46.  */
  47.  
  48. extern Vector3 X0;
  49. extern Vector3 Y0;
  50. extern Vector3 Z0;
  51. /*
  52. #define X0 Vector3(1,0,0)
  53. #define Y0 Vector3(0,1,0)
  54. #define Z0 Vector3(0,0,1)
  55. */
  56.  
  57. #endif
  58.